package netty.demo.nio.fileChannel;

import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * @author Zed
 * @description
 * @date 2022/10/22 22:36
 */
public class testFileCopy {
    public static void main(String[] args) throws Exception {
        String source = "E:\\ecloud";
        String target = "E:\\eCloudTestFileCopy";
        Files.walk(Paths.get(source)).forEach(path -> {
            try {
                String targetName = path.toString().replace(source, target);
                //是目录
                if (Files.isDirectory(path)) {
                    Files.createDirectory(Paths.get(targetName));
                } else if (Files.isRegularFile(path)) {
                    //是文件
                    Files.copy(path, Paths.get(targetName));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }
}
